package com.itlaobing.mvc.service;

import com.itlaobing.mvc.dao.EmployeeDao;
import com.itlaobing.mvc.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;
import java.util.logging.Logger;

@Service
public class EmployeeService {
    private Logger logger = Logger.getLogger( this.getClass().getName() );

    @Autowired
    private EmployeeDao employeeDao;

    public void save(Employee employee){
        logger.info("保存 :Service");
        LocalDate localDate = LocalDate.now();
        employee.setHireDate(localDate);
        logger.info(employee.toString());
        employeeDao.save(employee);
        logger.info(employee.toString());
    }

    public List<Employee> findAll(){
        logger.info("查找 :Service");
       return employeeDao.findAll();
    }

    public void remove(Integer id){
        logger.info("根据id删除 :Service");
        employeeDao.remove(id);
    }

    public EmployeeDao getEmployeeDao() {
        return employeeDao;
    }

    public void setEmployeeDao(EmployeeDao employeeDao) {
        this.employeeDao = employeeDao;
    }
}
